package com.lzy.cloud.permission.controller;

import com.alibaba.fastjson.JSON;
import com.lzy.cloud.permission.dtos.DozerA;
import com.lzy.cloud.permission.dtos.DozerB;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ellengou
 * Date: 2018-03-16
 * Time: PM 4:09
 */
@RestController
public class DcController {

    @Autowired
    DiscoveryClient discoveryClient;


    @GetMapping("/dc")
    public String dc() {

        DozerA dozerA = new DozerA();
        dozerA.setAge(18);
        dozerA.setName("ellen");
        dozerA.setSex("男");
        DozerB dozerB = new DozerB();
        dozerB.setAge(24);
        dozerB.setName("jack");
        dozerB.setSex("女");
        DozerB dozerC = DozerUtils.map(dozerA, DozerB.class);

        System.out.println(JSON.toJSON(dozerC));

        String services = "Services: " + discoveryClient.getServices();
        System.out.println(services);
        return services;
    }

}